{-# OPTIONS -Wall #-}

--------------------------------------------------------------------------------
-- |
-- Module      :  Lirio.ScoreDoc
-- Copyright   :  (c) Stephen Tetley 2012
-- License     :  BSD3
--
-- Maintainer  :  Stephen Tetley <stephen.tetley@gmail.com>
-- Stability   :  highly unstable
-- Portability :  GHC
--
-- Pretty printers to build scores.
--
--------------------------------------------------------------------------------


module Lirio.ScoreDoc
  (
    command
  
  , version
  , score

  , key
  , major
  , minor
  , clef
  , time

  -- * Titles and headers 
  , genHeaderDefn
  , dedication
  , title
  , subtitle
  , subsubtitle
  , poet
  , composer
  , meter
  , opus
  , arranger
  , instrument
  , piece
  , copyright
  , tagline

  ) where

import Lirio.Base.LyPrims
import Lirio.Base.Overloading
import Lirio.Base.Pitch
import Lirio.Score

import Control.Monad ( void )
import Data.Monoid



version :: String -> Score ()
version ss = command "version" <+> (dquotes $ text ss)


score :: Score ()
score = command "score"

key :: PitchLabel -> Score ()
key l = command "key" <+> genDoc (pitchLabelD l)


major :: Score ()
major = command "major"

minor :: Score ()
minor = command "minor"

clef :: String -> Score ()
clef name = command "clef" <+> string name

time :: Int -> Int -> Score ()
time n d = command "time" <+> int n <> char '/' <> int d



--------------------------------------------------------------------------------
-- ** Titles and headers

genHeaderDefn :: String -> Score a -> Score ()
genHeaderDefn name val = text name <+> equals <+> void val

-- | @dedication@.
--
dedication            :: Score a -> Score ()
dedication            = genHeaderDefn "dedication"


-- | @title@.  
--
title                 :: Score a -> Score () 
title                 = genHeaderDefn "title"

-- | @subtitle@.  
--
subtitle              :: Score a -> Score ()
subtitle              = genHeaderDefn "subtitle"

-- | @subsubtitle@.  
--
subsubtitle           :: Score a -> Score ()
subsubtitle           = genHeaderDefn "subsubtitle"

-- | @poet@.  
--
poet                  :: Score a -> Score ()
poet                  = genHeaderDefn "poet"

-- | @composer@.  
--
composer              :: Score a -> Score ()
composer              = genHeaderDefn "composer"

-- | @meter@.  
--
meter                 :: Score a -> Score ()
meter                 = genHeaderDefn "meter"

-- | @opus@.  
--
opus                  :: Score a -> Score ()
opus                  = genHeaderDefn "opus"

-- | @arranger@.  
--
arranger              :: Score a -> Score ()
arranger              = genHeaderDefn "arranger"

-- | @instrument@.  
--
instrument            :: Score a -> Score ()
instrument            = genHeaderDefn "arranger"

-- | @piece@.  
--
piece                 :: Score a -> Score ()
piece                 = genHeaderDefn "piece"

-- breakbefore is representated in the CHeaderElement class
-- because its argument is a bool.

-- | @copyright@.  
--
copyright             :: Score a -> Score ()
copyright             = genHeaderDefn "copyright"

-- | @tagline@.  
--
tagline               :: Score a -> Score ()
tagline               = genHeaderDefn "tagline"

